Skip to content

Use typed Search Attributes in TypeScript visibility samples - #319

Merged
Duncanma merged 1 commit into
mainfrom
duncan/ts-typed-search-attributes
Dec 3, 2026
Merged

Duncanma merged 1 commit into
mainfrom
duncan/ts-typed-search-attributes

Conversation

@Duncanma

@Duncanma Duncanma commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

For temporalio/sdk-typescript#1908. The TypeScript visibility samples used the deprecated searchAttributes record, so docs.temporal.io showed only the deprecated API.

Changes

  • Add visibility/search-attributes.ts, which defines the keys with defineSearchAttributeKey (new snippet typescript-observability-define-search-attribute-keys).
  • client.ts starts the Workflow with typedSearchAttributes and reads a value with describe().typedSearchAttributes.get(key).
  • workflows.ts reads with workflowInfo().typedSearchAttributes.get(key) and upserts { key, value } pairs. A null value removes an attribute.
  • observability.test.ts checks the values with describe() after each Workflow completes, because the Workflows no longer return the deprecated record.

Testing

  • npx tsc --noEmit passes.
  • mocha src/mocha/observability.test.ts -g Visibility passes (3 tests) against SDK 1.26.0.

The docs PR that syncs these snippets will follow as a draft.

Replace the deprecated searchAttributes record with defineSearchAttributeKey,
typedSearchAttributes, and the SearchAttributeUpdatePair form of
upsertSearchAttributes. Removing an attribute now sets it to null.

For temporalio/sdk-typescript#1908.
@Duncanma
Duncanma merged commit 51d954c into main Dec 3, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant